﻿using System;
using System.Windows.Forms;

namespace SPDevExplorer
{
    public partial class SiteExplorer
    {
        private void btnAddSite_Click(object sender, EventArgs e)
        {
            DlgNewSite dlg = new DlgNewSite();
            DialogResult res = dlg.ShowDialog();
            if (res == DialogResult.OK)
            {
                LoadSite(dlg.SiteUrl, dlg.Domain, dlg.UserName, dlg.Password);
            }
        }

        private void btnCommandPrompt_Click(object sender, EventArgs e)
        {
            try
            {
                Microsoft.Win32.RegistryKey k =
                    Microsoft.Win32.Registry.LocalMachine.OpenSubKey(
                        "SOFTWARE\\Microsoft\\Shared Tools\\Web Server Extensions\\12.0");
                string sLocation = (string) k.GetValue("Location");

                System.Diagnostics.Process.Start("cmd.exe", "/k cd \"" + sLocation + "bin\\\"");
            }
            catch (Exception ex)
            {
                // SvdO: Retry with Office14 as well
                try
                {
                    Microsoft.Win32.RegistryKey k =
                        Microsoft.Win32.Registry.LocalMachine.OpenSubKey(
                            "SOFTWARE\\Microsoft\\Shared Tools\\Web Server Extensions\\14.0");
                    string sLocation = (string) k.GetValue("Location");

                    System.Diagnostics.Process.Start("cmd.exe", "/k cd \"" + sLocation + "bin\\\"");
                }

                catch (Exception ex1)
                {
                    MessageBox.Show("SharePoint seems to be not installed on this server");
                }
            }
        }
    }
}